Netbooting Alpine Linux on RAM with iSCSI persisted Storage

Requirements

  1. iSCSI Server
  2. NFS Server
  3. HTTP Server running on same path as NFS Server (Port 6007)

Download Alpine Netboot Images and put on root of NFS and HTTP: vmlinuz-lts, initramfs-lts, modloop-lts Also configure router/DHCP Server to give out iPXE (possibly iPXE compiled with custom script to launch :6007/boot.ipxe)

Guide

  1. Use iPXE script:
set local_address http://<IP>:6007
set alpine_repo http://dl-cdn.alpinelinux.org/alpine/v3.21/main

kernel ${local_address}/vmlinuz-lts ip=dhcp alpine_repo=${alpine_repo} initrd=initramfs-lts modloop=${local_address}/modloop-lts pkgs=open-iscsi
initrd ${local_address}/initramfs-lts

boot
  1. setup-alpine, bei Disks Ctrl+C
  2. apk add nano
  3. nano /etc/lbu/lbu.conf und BACKUP_DIR=/boot
  4. add /boot NFS entry to boot server:
    1. apk add nfs-utils
    2. 10.10.13.236:/mnt/vault/boot /boot nfs4 rw,_netdev 0 0
    3. rc-update add nfsmount
    4. rc-service nfsmount start
  5. lbu ci
  6. Final iPXE script:
set local_address http://<ip>:6007
set alpine_repo http://dl-cdn.alpinelinux.org/alpine/v3.21/main
set apkovl ${local_address}/<hostname>.apkovl.tar.gz

kernel ${local_address}/vmlinuz-lts ip=dhcp apkovl=${apkovl} alpine_repo=${alpine_repo} initrd=initramfs-lts modloop=${local_address}/modloop-lts pkgs=open-iscsi
initrd ${local_address}/initramfs-lts

boot
  1. apk add open-iscsi
  2. edit /etc/iscsi/initiatorname.iscsi
  3. rc-service iscsid start
  4. rc-update add iscsid boot
  5. nano /etc/init.d/mount-after-iscsi
#!/sbin/openrc-run

description="Mount all filesystems after iSCSI login"

depend() {
    need iscsid
    after iscsid
    before docker # put any services that require the iSCSI mount here
}

start() {
    ebegin "Running mount -a"
    mount -a
    eend $?
}
  1. chmod +x /etc/init.d/mount-after-iscsi

  2. rc-update add mount-after-iscsi

  3. lbu inc /etc/init.d/mount-after-iscsi

  4. iscsiadm --mode discovery --type sendtargets --portal IP_OF_TARGET

  5. iscsiadm --mode node --targetname NAME_OF_TARGET --portal IP_OF_TARGET --login

  6. iscsiadm -m node -T NAME_OF_TARGET -p IP_OF_TARGET --op update -n node.conn[0].startup -v automatic

  7. lbu inc /var/lib/iscsi

  8. lbu ci

  9. Partition the iSCSI disk, add mount points to fstab, lbu ci and reboot

0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9